package com.xiaoyi;

import com.xiaoyi.equery.EQuery;
import com.xiaoyi.pooled.PooledDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author xiaoyi
 * @version 1.0.0
 * @date 2023/03/08 17:32:00
 */
@Configuration
@EnableConfigurationProperties(EqueryDataSourceProperties.class)
public class EqueryAutoConfigure {
    @Autowired
    private EqueryDataSourceProperties equeryDataSourceProperties;
   @Bean
   public EQuery eQuery(){
       PooledDataSource pooledDataSource = new PooledDataSource();
       pooledDataSource.setDriver(equeryDataSourceProperties.getDriverClassName());
       pooledDataSource.setUrl(equeryDataSourceProperties.getUrl());
       pooledDataSource.setUsername(equeryDataSourceProperties.getUsername());
       pooledDataSource.setPassword(equeryDataSourceProperties.getPassword());
       EQuery eQuery = new EQuery();
       eQuery.setPooledDataSource(pooledDataSource);
       return eQuery;
   }

}
